<template>
    <div class="xtrz">
        <div class="xtrz-top">
            <el-form :model="form" ref="form" label-width="80px" :inline="true" size="normal">
                <el-form-item label="用户名">
                    <el-input v-model="form.userName" placeholder="请输入用户名"></el-input>
                </el-form-item>
                <el-form-item label="模块名称">
                    <el-input v-model="form.name" placeholder="请输入模块名称"></el-input>
                </el-form-item>
                <el-form-item label="日志时间">
                    <el-date-picker v-model="form.time" type="daterange" range-separator="至" start-placeholder="开始日期"
                        end-placeholder="结束日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd">
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <div class="top-button">
                <el-button size="default" @click="chaxun"><i class="iconfont icon-sousuo"></i> 查 询</el-button>
                <el-button size="default" @click="chongzhi"><i class="el-icon-refresh"></i> 重 置</el-button>
            </div>
        </div>
        <div class="xtrz-middle">
            <el-table class="tableBox" :data="tableData" stripe height="90%" border :row-class-name="tableRowClassName"
                :header-cell-style="{ background: '#b2dffe', color: '#000' }" style="width: 100%">
                <el-table-column type="selection" align="center" width="50">
                </el-table-column>
                <el-table-column type="index" label="序号" align="center" width="50" :show-overflow-tooltip="true">
                    <template slot-scope="scope">
                        <div v-text="pagesize * (currentPage - 1) + 1 + scope.$index"></div>
                    </template>
                </el-table-column>
                <el-table-column prop="staff" label="用户名" width="250" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="name" label="模块名称" width="250" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="action" label="操作内容" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="createtime" label="日志时间" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="ip" label="IP" :show-overflow-tooltip="true">
                </el-table-column>
                <!-- <el-table-column prop="methodExecuteType" label="操作结果" :show-overflow-tooltip="true">
                </el-table-column> -->
            </el-table>
            <div class="bottom">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page.sync="currentPage" :page-size="pagesize" layout="total, prev, pager, next" :total="total">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
import { xtglxtrzlist } from '@/api/index'
export default {
    data() {
        return {
            // 主页头部表单
            form: {
                userName: '',
                name: '',
                time: ''
            },
            // 主页表格内容
            tableData: [],
            // 底部页码
            pagesize: 10,
            currentPage: 1,
            total: 10
        }
    },
    mounted() {
        this.xtrzlist();//获取表格数据
    },
    methods: {
        // 获取表格数据
        async xtrzlist() {
            const xtrzlistobj = {
                endTM: this.form.time[1],
                name: this.form.name,
                pageInfo: {
                    pageIndex: this.currentPage,
                    pageSize: this.pagesize
                },
                startTM: this.form.time[0],
                userName: this.form.userName
            }
            const res = await xtglxtrzlist(JSON.stringify(xtrzlistobj))
            // console.log(res);
            this.tableData = res.data.data.list
            this.total = res.data.data.total
        },
        handleSizeChange(val) {
            this.pageSize = val;
            // console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            this.currentPage = val
            this.xtrzlist();
        },
        // 表格的隔行颜色改变
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 == 0) {
                return 'statistiss-row'
            } else {
                return ''
            }
        },
        // 重置
        chongzhi() {
            this.form.userName = ''
            this.form.name = ''
            this.form.time = ''
            this.pagesize = 10
            this.currentPage = 1
        },
        chaxun() {
            this.xtrzlist();
        }
    }
}
</script>
<style lang="scss" scoped>
html,
body {
    height: 100%;
}

.xtrz {
    width: 100%;
    height: 100%;
    box-sizing: border-box;

    ::v-deep .xtrz-top {
        width: 97%;
        height: 10%;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        box-sizing: border-box;
        /* border: 1px solid red; */

        .el-form {
            /* width: 82%; */
            height: 100%;
            box-sizing: border-box;
            float: left;

            .el-form-item {
                padding-top: .625rem;
                padding-right: .625rem;

                .el-form-item__label {
                    background-color: #0055ab;
                    color: #fff;

                    .el-input {
                        width: 11rem;

                        .el-input__inner {
                            width: 100%;
                        }
                    }
                }

                .el-form-item__content {
                    line-height: 0;
                }
            }
        }

        .top-button {
            /* width: 18%; */
            height: 100%;
            padding-top: .625rem;
            box-sizing: border-box;
            float: right;

            .el-button {
                background-color: #0055ab;
                color: #fff;

                .iconfont {
                    font-size: .875rem;
                }
            }
        }
    }

    ::v-deep .xtrz-middle {
        width: 97%;
        height: 90%;
        margin: 0 auto;
        box-sizing: border-box;

        .el-table {
            width: 100%;
            height: 90%;
            background-color: rgb(243, 243, 243);
            padding-top: .625rem;

            .el-table__header-wrapper {}

            .el-table__body-wrapper {
                .el-icon-delete:before {
                    font-size: 1rem;
                    cursor: pointer;
                }

                .el-icon-edit {
                    cursor: pointer;
                }
            }
        }

        .bottom {
            width: 100%;
            height: 10%;

            .el-pagination {
                position: absolute;
                bottom: 3%;
                right: 6%;
            }
        }
    }
}

/* 控制top表单的宽度 */
/deep/.xtrz-top .el-input {
    width: 10rem !important;

    .el-input__inner {
        width: 100%;
    }
}

// 滚动条的宽度
/deep/ .el-table__body-wrapper::-webkit-scrollbar {
    width: .375rem; // 横向滚动条
    height: .125rem; // 纵向滚动条 必写
}

// 滚动条的滑块
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: .1875rem;
}

/* 表格的行高 */
/deep/ .tableBox {
    th {
        padding: 0 !important;
        height: 3.125rem;
        line-height: 3.125rem;
    }

    td {
        padding: 0 !important;
        height: 2.5rem;
        line-height: 2.5rem;
    }
}


// 鼠标经过颜色
/deep/ .el-table__body tr:hover>td {
    background-color: #d9effe !important;
}

/* 列标题的字体颜色 */
/deep/ .el-table th.el-table__cell>.cell {
    color: #000;
}

/* 内容的字体颜色 */
/deep/ .el-table--enable-row-transition .el-table__body td.el-table__cell {
    color: #000;
}

/* 表格隔行改变的颜色 */
/deep/ .el-table__row.statistiss-row {
    background-color: #f2faff;
}

/* @media all and (max-width:720px) and (min-width:320px) {

    body {

        background-color: red;

    }

    @media all and (max-width:320px) {

        body {

            background-color: blue;

        }

    }
} */
/* 去掉滚动条上方的小方块背景色 */
/deep/ .xtrz-middle .el-table--border th.el-table__cell.gutter:last-of-type {
    background: rgb(243, 243, 243);
    border: none;
}

/deep/ .el-table thead.is-group th.el-table__cell {
    background-color: #b2dffe;
}
</style>